using System;
using System.Collections.Generic;
using System.Text;

namespace SharpSoft.Data.DAL
{
    public class DAL_Base : IDisposable
    {
        public DAL_Base(Database p_db, int p_userid)
        {
            db = p_db;
            userid = p_userid;
        }

        protected Database db;
        protected int userid;

        public Database Database
        {
            get { return db; }
        }

        protected System.IO.Stream getResFile(string name)
        {
            Type type = this.GetType();
            var _namespace = type.Namespace;
            System.Reflection.Assembly _assembly = type.Assembly;

            var resourceName = _namespace + "." + name;
            System.IO.Stream stream = _assembly.GetManifestResourceStream(resourceName);
            return stream;
        }

        /// <summary>
        /// 返回用于创建数据结构的脚本
        /// </summary>
        /// <returns></returns>
        public virtual void CreateSchema()
        {

        }

        public void Dispose()
        {
            if (db != null)
            {
                db.Dispose();
            }
        }
    }
}
